const { defineConfig } = require('@vue/cli-service')
const webpack = require('webpack')

module.exports = defineConfig({
  transpileDependencies: true,
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true,
      builderOptions: {
        extraResources: ['.env'],
        files: [
          "**/*"
        ],
        asar: true,
        directories: {
          output: "dist_electron"
        }
      }
    }
  },
  configureWebpack: {
    resolve: {
      fallback: {
        "os": require.resolve("os-browserify/browser"),
        "crypto": require.resolve("crypto-browserify"),
        "stream": require.resolve("stream-browserify"),
        "http": require.resolve("stream-http"),
        "https": require.resolve("https-browserify"),
        "zlib": require.resolve("browserify-zlib"),
        "querystring": require.resolve("querystring-es3"),
        "timers": require.resolve("timers-browserify"),
        "fs": false,
        "path": require.resolve("path-browserify")
      }
    },
    plugins: [
      new webpack.ProvidePlugin({
        process: 'process/browser',
        Buffer: ['buffer', 'Buffer']
      }),
      new webpack.DefinePlugin({
        'process.env': {
          VUE_APP_ALIYUN_ACCESS_KEY_ID: JSON.stringify(process.env.VUE_APP_ALIYUN_ACCESS_KEY_ID),
          VUE_APP_ALIYUN_ACCESS_KEY_SECRET: JSON.stringify(process.env.VUE_APP_ALIYUN_ACCESS_KEY_SECRET)
        }
      })
    ]
  }
})
